<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
	<div data-type="layout" data-defs="fit:true,border:false">
		<div data-defs="region:'center',border:false" title="">
			<table id="org_gridtree" data-type="gridtree" title="组织机构信息" style="width: auto; height: 250px"
				data-defs="border:false,bodyCls:'byr',headerCls:'byb',
				iconCls: 'icon-role',
				rownumbers: true,
				animate: true,
				collapsible: true,
				fit:true,
				fitColumns: true,
				method:'post',url: '${rc.contextPath}/admin/queryOrgForTreeGrid.do',
				idField: 'orgId',
				treeField: 'orgName',
				toolbar:'#orgTreeGridToolBar'
			">
				<thead>
					<tr>
						<th data-defs="field:'orgName',width:180">组织机构名称</th>
						<th data-defs="field:'createDate',formatter:dateFormatter,width:120">创建日期</th>
						<th data-defs="field:'updateDate',formatter:dateFormatter,width:120">更新日期</th>
						<th data-defs="field:'createUserId',width:120">创建人主键</th>
						<th data-defs="field:'updateUserId',width:120">更新人主键</th>
					</tr>
				</thead>
			</table>
		</div>
		<div id="orgTreeGridToolBar" style="height: auto">
			<a href="#" onclick="addFun()" data-type="button" data-defs="iconCls:'icon-add',plain:true">新增</a>
			<a href="#" onclick="editFun()" data-type="button" data-defs="iconCls:'icon-edit',plain:true">编辑</a>
			<a href="#" onclick="deleteFun()" data-type="button" data-defs="iconCls:'icon-delete',plain:true">删除</a>
		</div>
		<div id="orgmanage_window" data-type="window" data-defs="modal:true,closed:true,iconCls:'icon-edit'"
			style="width: 600px; height: 300px; padding: 10px;">
			<form id="orgForm" method="post">
				<table class="stable" cellpadding="3" cellspacing="3" style="width: 100%">
					<!-- 组织机构主键 -->
					<input type="hidden" name="orgId"></input>
					<!-- 根节点标记 -->
					<input type="hidden" name="rootFlag"></input>
					<!-- 子节点标记 -->
					<input type="hidden" name="leafFlag"></input>
					<tr>
						<!-- 上级机构 -->
						<td width="25%" class="stdlabel">#springMessage("parentOrgName")</td>
						<td width="75%" class="stdinput">
							<input data-type="combotree" type="text" name="parentOrgId"
								data-defs="url: '${rc.contextPath}/admin/getOrgTree.do',
								method:'post',required:false"></input>
						</td>
					</tr>
					<tr>
						<!-- 组织机构名称 -->
						<td width="25%" class="stdlabel">#springMessage("orgName")</td>
						<td width="75%" class="stdinput">
							<input data-type="inputbox" type="text" name="orgName" data-defs="required:true"></input>
						</td>
					</tr>
					<tr>
						<!-- 排序号 -->
						<td width="25%" class="stdlabel">#springMessage("orderNum")</td>
						<td width="75%" class="stdinput">
							<input data-type="numberbox" type="text" name="orderNum" data-defs="required:true"></input>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<div style="margin: 0px 0; padding-top: 5px;" align="center">
								<a href="#" onclick="clearFun()" data-type="button" data-defs="iconCls:'icon-clear'">
									#springMessage("buttonClear") </a>
								<a onclick="saveFun()" href="#" data-type="button" data-defs="iconCls:'icon-save'">
									#springMessage("buttonSave") </a>
								<a onclick="closeFun()" href="#" data-type="button" data-defs="iconCls:'icon-close'">
									#springMessage("buttonClose") </a>
							</div>
						</td>
					</tr>
				</table>
			</form>
		</div>
	</div>
	<script type="text/javascript">
		$(document).ready(function() {
        });
        function addFun() {
	        var options = {
	            "windowId" : "orgmanage_window",
	            "width" : 500,
	            "height" : 200,
	            "title" : "#springMessage('orgManageEdit')"
	        };
	        openWindow(options);
	        $("#orgForm").form('clear');
        }
        function editFun() {
	        var selectedRow = $('#org_gridtree').gridtree('getSelected');
	        if (selectedRow == null || selectedRow.length == 0) {
		        showMsg('#springMessage("unSelectedMsg")');
		        return;
	        }
	        var options = {
	            "windowId" : "orgmanage_window",
	            "width" : 500,
	            "height" : 200,
	            "title" : "#springMessage('orgManageEdit')"
	        };
	        openWindow(options);
	        $("#orgForm").form('clear');
	        var url = "${rc.contextPath}/admin/getOrgDetail.do?orgId=" + selectedRow.orgId;
	        $("#orgForm").form('load', url);
        }
        function deleteFun() {
	        $("#orgForm").form('clear');
	        var selectedRow = $('#org_gridtree').gridtree('getSelected');
	        if (selectedRow == null || selectedRow.length == 0) {
		        showMsg('#springMessage("unSelectedMsg")');
		        return;
	        }
	        confirmMsg('#springMessage("confirmDelete")', function(r) {
		        if (r) {
			        var url = '${rc.contextPath}/admin/deleteOrg.do';
			        var data = {
				        "orgId" : selectedRow.orgId
			        };
			        ajaxPost(url, data, function(rs) {
				        showMsg(rs.msgInfo);
				        $('#org_gridtree').gridtree("reload");
			        });
		        }
	        });
        }
        function clearFun() {
	        $("#orgForm").form('clear');
        }
        function saveFun() {
	        var url = "${rc.contextPath}/admin/saveOrg.do";
	        var v = $("#orgForm").form('validate');
	        if (!v) {
		        return;
	        }
	        submitForm("orgForm", url, function(rs) {
		        var returnedObj = $.parseJSON(rs);
		        showMsg(returnedObj.msgInfo);
		        $("#orgForm").form('load', {
			        "orgId" : returnedObj.data
		        });
		        $('#org_gridtree').gridtree("reload");
	        });
        }
        function closeFun() {
	        $("#orgmanage_window").window("close");
        }
	</script>
</body>
</html>